class Solution {
public:
    vector<string> ret;
    string path;
    vector<string> letterCasePermutation(string s) {
        dfs(s,0);
        return ret;
    }

    void dfs(string s,int k)
    {
        if(k==s.size())
        {
            ret.push_back(path);
            return;
        }
        if(isdigit(s[k]))
        {
            path.push_back(s[k]);
            dfs(s,k+1);
            path.pop_back();
        }
        else
        {
            path.push_back(s[k]);
            dfs(s,k+1);
            path.pop_back();

            if(s[k]>='a'&&s[k]<='z')
            {
                path.push_back(s[k]-('a'-'A'));
            }
            else
            {
                path.push_back(s[k]+('a'-'A'));
            }
            dfs(s,k+1);
            path.pop_back();
        }

    }
};